# -*- encoding: utf-8 -*-
"""
    无人机GSD计算.py
    :description: 
    :date: 2024/05/16 17:30:00
    :version      :1.0
    :copyright: (c) 2024 by enjoyZHou
"""

import math

# 英寸转厘米


def inches_to_mm(inches):
    return inches * 25.4

# 计算像素点的物理大小


def get_pixel_size(soc_w, soc_h, p_w, p_h):
    soc_p = math.sqrt(soc_w**2 + soc_h**2)
    p_p = math.sqrt(p_w**2 + p_h**2)
    print(soc_p, p_p)
    return (float(soc_p) / p_p) * 1000


def get_gsd(hight, focal, soc_w, soc_h, p_w, p_h):
    """
    Calculate the Ground Sample Distance (GSD) based on the input parameters.

    :param hight: Height of the drone in meters.
    :param focal: Focal length of the camera in millimeters.
    :param inches: Size of the camera sensor in inches.
    :param p_w: Width of the pixel in the camera sensor.
    :param p_h: Height of the pixel in the camera sensor.
    :return: m/pixel Calculated Ground Sample Distance (GSD) in meters.
    """
    p_s = get_pixel_size(soc_w, soc_h, p_w, p_h)
    print(p_s)
    return hight / (focal * p_s)



gsd = get_gsd(200, 24, 9.65, 7.2, 8064, 6048)

print(gsd)
